package org.fastsyncer.manager.listener.mysql.binlog.impl.variable.status;

import java.io.IOException;

import org.fastsyncer.manager.listener.mysql.common.glossary.column.StringColumn;
import org.fastsyncer.manager.listener.mysql.common.util.MySQLConstants;
import org.fastsyncer.manager.listener.mysql.common.util.ToStringBuilder;
import org.fastsyncer.manager.listener.mysql.io.XInputStream;

public class QCatalogCode extends AbstractStatusVariable {
	public static final int TYPE = MySQLConstants.Q_CATALOG_CODE;

	private final StringColumn catalogName;

	public QCatalogCode(StringColumn catalogName) {
		super(TYPE);
		this.catalogName = catalogName;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this)
		.append("catalogName", catalogName).toString();
	}

	public StringColumn getCatalogName() {
		return catalogName;
	}

	public static QCatalogCode valueOf(XInputStream tis) throws IOException {
		tis.readInt(1); // Length
		return new QCatalogCode(tis.readNullTerminatedString());
	}
}
